<?php
$this->breadcrumbs=array(
	Yii::t('app', 'Купоны')=>array('admin'),
	Yii::t('app', 'Поиск купона'),
);
?>
<div class="title">
<h2> Поиск купона </h2></div>
<div class="search-form2" >
<?php
 $this->renderPartial('_searchcup');
?>
    </div>
<div class="content">
<?php 
if (is_string($model)) {
?>
    <p><?= $model ?></p>
    <?php } else { 
        $tim=time();
        ?>
    

    
    <table width="100%" border="1">
  <tr>
    <th width="25%" scope="row">ИДЕНТИФИКАТОР КУПОНА</th>
    <td><?= $model->cuppon_id ?></td>
  </tr>
  <tr>
    <th scope="row">ВЛАДЕЛЕЦ КУПОНА</th>
    <td><a href="<?=  '/user/profile/'.$model->owner->id  ?>"><?= $model->owner->username ?></td>
  </tr>
  <tr>
    <th scope="row">ПОКУПАТЕЛЬ КУПОНА</th>
    <td><a href="<?= '/user/profile/'.$model->byer->id  ?>"><?= $model->byer->username ?></td>
  </tr>
  <tr>
    <th scope="row">ЦЕНА КУПОНА</th>
    <td><?= $model->cuppon_price ?></td>
  </tr>
  <tr>
    <th scope="row">ДАТА ПОКУПКИ</th>
    <td><?= $model->add_time ?></td>
  </tr>
    <tr>
    <th scope="row">Статус</th>
    <td><?php
    $dd=false;
    if ($model->used==0) 
    {
        ?>
        <span>не использван,</span>
        
        
         <?php
            $sratr=strtotime($model->share->begin_time_cuppons);
            $end=strtotime($model->share->last_time_cuppons);
            if (($tim>$sratr)
                &&
                ($tim<$end))
            {
                $dd=true;
            ?>
            <span class="oranj">Действующий,</span>
            
            <?php } 
           elseif ($tim>$end)
           {
            ?>
            <span class="gray">Истекший,</span>
            <?php } ?>
        
        
        <?php } else {?>
          <span>использван,</span>
          <?php } ?>
       <?php if ($model->deleted) {?>
    <strong style="color: red">удалён</strong>
    <?php } else { ?>
    <strong>не удалён</strong>
    <?php } ?>
    </td>
  </tr>
</table>
 <form action="<?= $this->createUrl('cupdel')?>" method="post" class="form">
      <input name="id" type="hidden" value="<?= $model->cuppon_id ?>" />
      <?php if ($model->deleted) {?>
      <input name="act" type="hidden" value="rest" />
     <button type="submit" class="green big">
  <span>Востановить</span>
</button>
     <?php } else {?>
     <input name="act" type="hidden" value="del" />
<button type="submit" class="green red">
  <span>Удалить</span>
</button>
 <?php } ?>
</form>
    <?php } ?>
</div>